package PTA.Mianxiangduixiang.ex05;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
class PersonOverride{
private String name;
private int age;
private boolean gender;

    public PersonOverride(String name, int age, boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public PersonOverride() {
        this("default",1,true);
    }

    @Override
    public String toString() {
        return  name+"-"+age+"-"+gender;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PersonOverride that = (PersonOverride) o;
        return age == that.age && gender == that.gender && Objects.equals(name, that.name);
    }

}

public class ex05 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
     //输入n1，使用无参构造函数创建n1个对象，放入数组persons1。
            int n1 = sc.nextInt();
            boolean f = true;
            sc.nextLine();
        ArrayList<PersonOverride> p1 = new ArrayList<>();
        for(int i=0;i<n1;i++){
            p1.add(new PersonOverride());
        }
     // 输入n2，然后指定name age gender
     int n2 = sc.nextInt();
        sc.nextLine();
        for(int i=0;i<n2;i++){
            f=true;
            PersonOverride a = new PersonOverride(sc.next(),sc.nextInt(),sc.nextBoolean());
            sc.nextLine();
            for(PersonOverride s:p1){
                if(s.equals(a)){
                    f=false;
                    break;
                }
            }
            if(f){
                p1.add(a);
            }
        }
        for(PersonOverride s:p1){
            System.out.println(s.toString());
        }
        System.out.println(p1.size()-n1);
        System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));


    }
}
